﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.hud.components {
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import com.greensock.*;
    import flash.filters.*;
    import Display.aswingui.*;

    public class HUDVisitingEnergyComponent extends HUDComponent {

        private var m_visitEnergy:uint;
        private var m_icon:Component;
        private var m_visitEnergyCounter:JTextField;

        public function HUDVisitingEnergyComponent(){
            this.m_visitEnergy = Global.gameSettings.getInt("maxVisitingEnergy", 5);
            this.m_icon = null;
            this.m_visitEnergyCounter = null;
            super();
        }
        override public function isVisible():Boolean{
            return ((this.m_visitEnergy > 0));
        }
        override protected function buildComponent():void{
            var _local3:Container;
            var _local4:AssetPane;
            var _local5:Container;
            m_jPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.LEFT, 0);
            var _local1:Number = Global.gameSettings.getInt("visitingEnergyIconAppearDelay", 200);
            var _local2:Number = (Global.gameSettings.getInt("visitingEnergyIconAppearTime", 1000) / 1000);
            if (this.m_visitEnergy > 0){
                _local3 = ASwingHelper.makeSoftBoxJPanel(1, -20);
                _local4 = new AssetPane((new EmbeddedArt.visitEnergyIcon() as DisplayObject));
                _local5 = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.BOTTOM);
                this.m_visitEnergyCounter = ASwingHelper.makeTextField(this.getCounterText(this.m_visitEnergy), EmbeddedArt.TITLE_FONT, 24, EmbeddedArt.yellowTextColor);
                this.m_visitEnergyCounter.filters = [new GlowFilter(EmbeddedArt.orangeTextColor, 1, 3, 3, 5, BitmapFilterQuality.LOW), new DropShadowFilter(1, 45, EmbeddedArt.blackTextColor, 0.6, 3, 3, 6)];
                _local5.append(new AssetPane(this.m_visitEnergyCounter));
                _local3.append(_local4);
                _local3.append(_local5);
                m_jPanel.append(_local3);
                this.m_icon = _local3;
                this.m_icon.alpha = 0;
            };
        }
        override public function refresh(_arg1:Boolean):void{
            super.refresh(_arg1);
            this.updateCounter(this.m_visitEnergy);
        }
        override public function updateCounter(... _args):void{
            var _local2:uint = _args[0];
            var _local3:uint = Math.min(Math.max(_local2, 0), Global.gameSettings.getInt("maxVisitingEnergy", 5));
            this.m_visitEnergy = _local3;
            var _local4:Number = (Global.gameSettings.getInt("visitingEnergyIconAppearTime", 1000) / 1000);
            this.m_visitEnergyCounter.setText(this.getCounterText(_local3));
            if (_local3 <= 0){
                TweenLite.to(this.m_icon, _local4, {alpha:0});
            } else {
                TweenLite.to(this.m_icon, _local4, {alpha:1});
            };
        }
        private function getCounterText(_arg1:int):String{
            return ((("x" + _arg1.toString()) + " "));
        }

    }
}//package Display.hud.components 
